home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / eulisp / mpfeel.lha / MPFeel / Modules / fact.em < prev    next >
Lisp/Scheme  |  1992-10-06  |  621b  |  20 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                           ;;
  3. ;;  EuLisp Module                     Copyright (C) University of Bath 1991  ;;
  4. ;;                                                                           ;;
  5. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6.  
  7. (defmodule fact
  8.  
  9.   (standard) ()
  10.  
  11.   (defun fact (n) (if (= n 0) 1 (* (fact (- n 1)) n)))
  12.  
  13.   (defun rfact (n) (rfact-aux n 1))
  14.  
  15.   (defun rfact-aux (n tot)
  16.     (cond ((= n 0) tot)
  17.       (t (rfact-aux (- n 1) (* n tot)))))
  18.  
  19. )
  20.